﻿using System.Collections.Generic;

namespace Exercise12
{
    internal class MyStrFun
    {
        public List<char> ListChars;
        public string ReStr;
        User User;
        public User StrRemoveNum(string Instring)
        {
            User = new User(false, "Pass");
            if (string.IsNullOrEmpty(Instring)) { User.bIsNull = true; User.StrMsg = "Is Null Or Empty"; return User; }            
            ReStr = System.Text.RegularExpressions.Regex.Replace(Instring, @"\d", "");
            return User;
        }
        /// <summary>
        /// 使用char接去除
        /// </summary>
        /// <param name="Instring"></param>
        /// <returns></returns>
        public User StrRemoveNum1(string Instring)
        {
            int Count = 0;
            User = new User(false, "Pass");            
            char[] OutStr = new char[Instring.Length];            
            if (string.IsNullOrEmpty(Instring)) { User.bIsNull = true; User.StrMsg = "Is Null Or Empty"; return User; }
            foreach (char item in Instring) {
                if (char.IsDigit(item)) { continue; }
                OutStr[Count++] = item; 
            }
            ReStr = new string(OutStr);            
            return User;
        }
        /// <summary>
        /// 使用list接char
        /// </summary>
        /// <param name="Instring">输入的字符串</param>
        /// <returns>user</returns>
        public User StrRemoveNum2(string Instring)
        {
            ListChars = new List<char>();
            User      = new User(false, "Pass");
            if (string.IsNullOrEmpty(Instring)) { User.bIsNull = true; User.StrMsg = "Is Null Or Empty"; return User; }
            foreach (char item in Instring) {
                if (char.IsDigit(item)) { continue; }
                ListChars.Add(item);
            }
            return User;
        }
    }
}
